<!DOCTYPE html>
<head>
    <#assign dicSelect=JspTaglibs["http://www.casic304.cn/dicSelect"] />
    <#assign secSelect=JspTaglibs["http://www.casic304.cn/secSelect"] />
    <#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
    <meta charset="utf-8">
    <title>专家信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <!--<link rel="stylesheet" href="/qbdmsStatic/style/forms/currencyCss.css">-->
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
    <div class="qbdms-bodyDiv">
        <div class="layui-table-view-body qbdms-add-view-body">
        <form class="layui-form" requrl="${ctx}/qbdms/wQbdTeamExpertgroup/get" lay-filter="wQbdTeamExpertgroupDataForm">
            <div class="qbdms-formTitle">专家信息<i class="qbdms-returnOn closeWindow">返回</i></div>
            <div class="qbdms-formBody">
            <@fillDept.dept id="tbxx"/>
            <div class="layui-row">
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@secSelect.sec_select data_src=1 required=true name="secret"/>
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="姓名">姓名<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="name" lay-reqtext="姓名是必填项" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" maxlength="15" lay-verify="required">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="类别">类别<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="classification" reqtext="类别是必填项" verify="required" nodeKey="zjlb" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="初评年度">初评年度<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="assessmentyear" placeholder="请输入" lay-verify="required"
                               readonly="readonly" autocomplete="off" lay-reqtext="初评年度是必填项" class="layui-input years">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="技术领域">技术领域<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="technical" reqtext="技术领域是必填项" verify="required" nodeKey="zjjzly" />
                    </div>
                </div>


                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="工作单位">工作单位<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="workdept" placeholder="请输入" lay-verify="required"
                               autocomplete="off" lay-reqtext="工作单位是必填项" maxlength="60" class="layui-input  textInput">
                    </div>
                </div>


                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="核定年度">核定年度<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="approvedyear" lay-reqtext="核定年度是必填项" placeholder="请输入" lay-verify="required"
                               readonly="readonly" autocomplete="off" class="layui-input years" >
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="性别">性别<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="sex" verify="required" reqtext="性别是必填项" nodeKey="zjxb" />
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="身份证号">身份证号<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="idnumber" lay-verify="identity|required" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" id="idnumber"
                               lay-reqtext="身份证号是必填项" maxlength="20" fieldname="idnumber">
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="年龄">年龄</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="age" placeholder="自动计算"
                               autocomplete="off" class="layui-input textInput isReadonlyInput"
                               maxlength="3" readonly="readonly" id="age">
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="组内职务">组内职务<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="groupduty" verify="required" reqtext="组内职务是必填项" nodeKey="znzw" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="民族">民族<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="nation" search=true verify="required" reqtext="民族是必填项" nodeKey="mz" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="政治面貌">政治面貌</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="politicalaspects" nodeKey="zzmm" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="行政职务">行政职务</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="admpositions" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" maxlength="30" >
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="技术职务">技术职务</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="techpositions" nodeKey="jzzw" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="技术职称">技术职称</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="techtitle" nodeKey="jzzc" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="所学专业">所学专业</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="major" search=true nodeKey="sxzy" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="从事专业">从事专业</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="workindustry" search=true nodeKey="cszy" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="联系电话（手机）">联系电话（手机）</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="mobile" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" lay-verify="num"
                               maxlength="11" >
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="办公室座机">办公室座机</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="tel" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" lay-verify="servicePhone"
                               maxlength="50" >
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="是否在职">是否在职</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="iswork" search=true nodeKey="sf" />
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="退休/返聘">退休/返聘</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="workstatus" search=true nodeKey="txfp" />
                    </div>
                </div>
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="通讯地址">通讯地址</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="address" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput"
                               maxlength="50" >
                    </div>
                </div>

                <div class="qbdms-textarea  ">
                    <label class="layui-form-label qbdms-label">备注</label>
                    <div class="layui-input-block qbdms-input">
                       <textarea type="text" name="remark" placeholder="请输入" autocomplete="off"
                                 class="layui-textarea  textInput" maxlength="300" fieldname="remark"></textarea>
                    </div>
                </div>

                <div class="qbdms-textarea  ">
                    <label class="layui-form-label qbdms-label">推荐表</label>
                    <div class="layui-input-block qbdms-input">
                        <div class="doNotDelThisDiv layui-input-inline">
                            <div class="uploadFileCont">
                                <button type="button"
                                        class="layui-btn fileUpload qbdms-fileUp iconfont iconupload"
                                        id="fRecommendationfileList">上传附件</button><i class="qbdms-fileUpText">支持单个附件上传，附件格式：doc  docx    pdf，文件大小限制不超过100M</i>
                                <input type="text" id="recommendfile" class="uploadInput"
                                       name="recommendfile" fieldname="recommendfile" style="display: none">
                                <div class="uploadFileList" fileUploadName="recommendfile"></div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-hide">
                    <input type="text" name="id" placeholder=""
                           autocomplete="off" class="layui-input  textInput"
                           maxlength="50" fieldname="id">
                    <input type="text" name="workdeptid" placeholder=""
                           autocomplete="off" class="layui-input  textInput"
                           maxlength="50" fieldname="workdeptid">
                </div>

                <div class="layui-form-item btnformItem">
                    <p>
                    <span id="hideAndShow" style="display: none;">
                        <a lay-submit lay-filter="wQbdTeamExpertgroup" class="layui-btn btn-n privateSubmit qbdms-oneBtn"
                           requrl="${ctx}/qbdms/wQbdTeamExpertgroup/save">提交</a>
                    </span>
                        <button type="reset" id="closeWindow" style="margin-left: 10px;"
                                class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消
                        </button>
                    </p>
                </div>
            </div>
            </div>
        </form>
    </div>
</div>

<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>

    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','setter', 'propsHandle', 'laydate', 'jquery','commonDialog', 'common','publicMethods','qbdmsForm'], function () {
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var form = layui.qbdmsForm;
        var common = layui.common;
        var upload = layui.upload;
        var publicMethods = layui.publicMethods;
        var setter = layui.setter;
        var ice = layui.ice;
        var propsHandle = layui.propsHandle;
        var dateTimeFiledLen = $(".dateTimeFiled");

        var  defProps = {
            //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
            viewMould: 'moulds/', // 组件模块 存放文件 *****
            formAreaInfo: '.formPreview',
            formAreaInfo: 'html',
            temDate: '.temDate',
            uploadFileBtn: '.uploadFileBtn',
            uploadImgBtn: '.uploadImgBtn',
            richTextArea: '.richTextArea',
            selectInput: '.selectInput',
            radioOptionCont: '.radioOptionCont',
            dataLexiTree: '.dataLexiTree',
            selectorBtn: '.selectorBtn'
        },
            temQuery = new propsHandle();  // 实例化模板功能部分

        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });


        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'date'
                , trigger: 'click'
            });
        }
        var dateYears = $(".years");
        for (var i = 0; i < dateYears.length; i++) {
            laydate.render({
                elem: dateYears[i] //指定元素
                , type: 'year'
                , trigger: 'click'
            });
        }

        $(function () {
            $("input[name='idnumber']").on("input", function (e) {
                if (e.delegateTarget.value.length > 14) {
                    var idnumber = $("#idnumber").val();
                    var birth = 0;
                    if (idnumber.length === 15) {
                        birth = '19' + idnumber.substr(6, 2);
                    } else if (idnumber.length === 18) {
                        birth = idnumber.substr(6, 4);
                    } else if (idnumber.length > 18) {
                        $("#age").val("");
                        return;
                    }

                    if (birth !== 0) {
                        var date = new Date();
                        var year = date.getFullYear();
                        var age = parseInt(year) - parseInt(birth);
                        if (!isNaN(age) && age > 0) {
                            $("#age").val(age);
                        }
                    }

                } else {
                    $("#age").val("");
                }
            });
        });

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = '${ctx}/qbdms/wQbdTeamExpertgroup/view/list';
        });

        var runId = "${runId}";
        if (runId == null || runId == '') {
            $("#hideAndShow").show();
        }

        form.verify({
            num: function (value,item) {
                // 如果值为空，不触发校验
                if (value && !new RegExp(/^1[3456789]\d{9}$/).test(value)) return common.verifyTitleAdd(item) + "手机号码有误";

            },
            servicePhone: function (value,item) {
                // 如果值为空，不触发校验
                // if (value && !new RegExp(/^$|(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/).test(value)) return "座机格式不正确";
                if (value && !new RegExp(/^([0-9]{1,6}[-]?)?([0][1-9][0-9]{1,2}[-]?)?[0-9]{6,8}$/).test(value)) return common.verifyTitleAdd(item) + "座机格式不正确";
            }
        });

        //-- 附件上传 开始 --------------------------------------------------------------
        //下载附件
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        }
        // 删除
        $(document).on('click', '.deleteFile', function () {
            $(".uploadFileList").each(constructFileStr);
        });
        common.uploadfun(".fileUpload", {
            acceptMime: '${wjszsdsxlx}',
            exts: "${fileManagementUploadType}",
            secSelect: '<@secSelect.sec_select data_src=1 hasBlank=false/>',
            isSub: false,
            upLoadSize: 102400
        });


        //构建file的字符串
        function constructFileStr() {
            var filesJsonStr = "";
            $(this).find(".file-id").each(function () {
                var fileId = $(this).attr("fileid");
                var fileName = $(this).find("span").text();
                var fileLevel = $(this).find("option:selected").val();
                var fileLevelText = $(this).find("option:selected").text();
                filesJsonStr += '{"fileId":"' + fileId + '","fileName":"' + fileName + '","fileLevel":"' + fileLevel + '", "fileLevelText":"' + fileLevelText + '"},';
            });
            filesJsonStr = filesJsonStr.substring(0, filesJsonStr.length - 1);
            if (filesJsonStr != "") {
                filesJsonStr = '[' + filesJsonStr + ']';
            }
            var fileUploadName = $(this).attr("fileUploadName");
            $("#" + fileUploadName).val(filesJsonStr);
        }

        //-- 附件上传 结束 --------------------------------------------------------------

        var common = layui.common;
        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name: 'wQbdTeamExpertgroupDataForm',
            idValue: "${id}",
            primary: "id",
            beforeSubmitFun: function (data) {

                //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
                var selectMaxVal = 0;
                var formSecretVal = $("[name='secret']").val();
                $(".fileSecLevel select").each(function () {
                    selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                });

                if (selectMaxVal > formSecretVal) {
                    layer.msg('附件密级不能高于表单密级。', {icon: 5});
                    return false;
                }
                //- 附件密级不能高于表单密级 结束 ------------------------------------------------------
                $(".uploadFileList").each(constructFileStr);

                var files=[];
                //整理上传附件的隐藏域，将提交的字符串转为json对象
                $(".uploadInput").each(function () {
                    var uploadName = $(this).attr("name");
                    if (!$(this).val()) {
                        return;
                    }
                    data.field[uploadName] = eval($(this).val());
                    files=files.concat(eval($(this).val()));
                });

                return common.setFileLevel(files);
            },
            getCallback: function (data) {
                //-修改页面 初始化附件组件 开始 ------------------------------------------
                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);
                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont data-iconcommon_fujian" style="margin-right: 5px"></i>' + files[i].fileName + '</span><i class="iconfont data-iconcommon_close deleteFile" ></i></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            // $(this).find("select:last").attr("disabled", "disabled");
                        }
                    }
                });
                //-修改页面 初始化附件组件 结束 ------------------------------------------
            },
            updateCallback: function (data) {
                if (common.filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = '${ctx}/qbdms/wQbdTeamExpertgroup/view/list';
                    });
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                }
                return false;
            }
        });
    });
</script>
</body>
</html>